@layout("/common/_container.html"){
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal" id="itemsInfoForm">

            <div class="row">
                <div class="col-sm-6 b-r">
<!--                            <#input id="id" name="账目id" underline="true"/>-->
<!--                            <#input id="accountid" name="账户id" underline="true"/>-->
<!--                            <#input id="createtime" name="创建时间"/>-->
<!--                            <#input id="paykind" name="支出类型" underline="true"/>-->

                            <#select id="accountid" name="账户" underline="true" >
                                @for(items in accounts){
                                <option value="${items.id}">${items.accountname}</option>
                                @}
                            </#select>


                            <div class="form-group">
                                <label class="col-sm-3 control-label">收/支</label>
                                <div class="col-sm-9">
                                    <select class="form-control" id="shouZhi" name="收/支" onchange="changeShouZhi()">
                                        <option value="zclx">支出</option>
                                        <option value="srlx">收入</option>
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>



                            <#select id="paykind" name="收支类型" underline="true" >
                            </#select>

                            <#input id="pay" name="收支金额" underline="true"/>



                </div>

                <div class="col-sm-6">
<!--                            <#input id="updatetime" name="更新时间" underline="true"/>-->
<!--                            <#input id="spare1" name="空闲字段1" underline="true"/>-->
<!--                            <#input id="spare2" name="空闲字段2" underline="true"/>-->
<!--                            <#input id="spare3" name="空闲字段3" underline="true"/>-->
<!--                            <#input id="updateid" name="更新人" underline="true"/>-->
                    <#input id="remark" name="备注" underline="true"/>
                    <#input id="paytime" name="收支时间" underline="true"/>
                    <#input id="payplace" name="收支地点" underline="true"/>
                </div>
            </div>

            <div class="row btn-group-m-t">
                <div class="col-sm-10">
                    <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="ItemsInfoDlg.addSubmit()"/>
                    <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="ItemsInfoDlg.close()"/>
                </div>
            </div>
        </div>

    </div>
</div>
<script src="${ctxPath}/static/modular/items/items/items_info.js"></script>
<script language="JavaScript">

    laydate.render({
        elem:'#paytime',trigger:'click',type:'datetime'
    });

    var classzhichu=[];
    var namezhichu=[];
    var classshouru=[];
    var nameshouru=[];

    function ajax1() {
        $.ajax({
            type: "post", // 以get方式发起请求
            url: Feng.ctxPath + "/items/getMessage", // 将你的请求参数以问号拼接到url中进行参数传递
            success(data) {
                for(var d in data){
                    if(data[d]['v1']=="zclx"){
                        classzhichu.push(data[d]['v2']);
                        namezhichu.push(data[d]['v3']);

                    }
                    else if(data[d]['v1']=="srlx"){
                        classshouru.push(data[d]['v2']);
                        nameshouru.push(data[d]['v3']);

                    }
                    // alert(data[d]['v2']+" "+data[d]['v3']);
                }

                //保证初始时第二个下拉框中有值
                for(var i=0;i<classzhichu.length;i++){
                    option = new Option(namezhichu[i],classzhichu[i] );
                    paykind.options.add(option);
                }
            },
            error(data){
                alert("cuowu");
            }

        })
    }
    ajax1();


    function changeShouZhi() {

        var value =$('#shouZhi').val();
        var shouru=document.getElementById("shouZhi");
        var paykind=document.getElementById("paykind");
        paykind.options.length = 0;
        if(value=="zclx"){
            for(var i=0;i<classzhichu.length;i++){
                option = new Option(namezhichu[i],classzhichu[i] );
                paykind.options.add(option);
            }
        }
        else if(value=="srlx"){
            for(var i=0;i<classshouru.length;i++){
                option = new Option(nameshouru[i],classshouru[i]);
                paykind.options.add(option);
            }
        }


    }


</script>

@}
